<template>
  <div>
    <el-dialog
      title=""
      :visible.sync="dialogVisible"
      width="40%"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      @close="resetForm"
    >
      <el-descriptions
        title="详细信息"
        :column="2"
      >
        <el-descriptions-item label="设备名称">{{ ruleForm.device_name }}</el-descriptions-item>
        <el-descriptions-item label="设备编号">{{ ruleForm.device_num }}</el-descriptions-item>
        <el-descriptions-item label="站点名称">{{ ruleForm.site_name }}</el-descriptions-item>
        <el-descriptions-item label="分组">{{ ruleForm.group_name }}</el-descriptions-item>
        <el-descriptions-item label="设备类型">{{ ruleForm.device_typename }}</el-descriptions-item>
        <el-descriptions-item label="关联摄像">{{ ruleForm.camera }}</el-descriptions-item>
        <el-descriptions-item label="指标" label-style="width: 100px;">
          <template  v-for="item in ruleForm.target_list">
            <el-tag type="info" size="mini">{{ item.type_name }}</el-tag>
          </template>
          <template  v-for="item in ruleForm.target_list">
            <el-tag type="info" size="mini">{{ item.type_name }}</el-tag>
          </template>
        </el-descriptions-item>
        <el-descriptions-item label="是否参与计算">
          <el-tag
            :type="ruleForm.calculate === 1 ? 'success' : 'danger'"
            size="mini"
          >
            {{ ruleForm.calculate === 1 ? '是' : '否' }}
          </el-tag>
        </el-descriptions-item>
      </el-descriptions>
      <div style="display: flex;justify-content: flex-end">
        <el-button type="primary" @click="resetForm">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { detailCamera } from '@/api/fileManage'

export default {
  name: 'info',
  props: {
    id: {
      type: Number,
      default: 0
    },
    dialogVisible: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      optionsType: [],
      optionsSite: [],
      ruleForm: {}
    }
  },
  created() {
    this.getDetailById(this.id)
  },
  methods: {
    // 获取详情
    getDetailById(id) {
      detailCamera({ id }).then(res => {
        this.ruleForm = res.data
      })
    },
    // 表单重置
    resetForm() {
      this.$emit('close')
    }
  }
}
</script>

<style scoped>

</style>
